package mylib.archive.y2012.m08.SNSS_R4;

import mylib.dir.FastInputReader;
import mylib.dir.StringUtils;

import java.io.PrintWriter;
import java.util.HashMap;

public class TaskE {
    HashMap<String, Character> dict = new HashMap<String, Character>();
    HashMap<Character, String> idict = new HashMap<Character, String>();

    {
        String s = ".-  -...  -.-.  -.. .  ..-.  --.  ....  ..  .---  -.-  .-.. --  -.  ---  .--. --.-  .-.  ...  - ..-  ...-  .--  -..- -.--  --..";
        String[] spl = StringUtils.removeEmptyEntry(s.split(" "));
        for (int i = 0; i < 26; ++i) {
            dict.put(spl[i], (char) (i + 'A'));
            idict.put((char) (i + 'A'), spl[i]);
        }
    }

    long[] count;
    String s;

    public void solve(int testNumber, FastInputReader in, PrintWriter out) {
        s = in.nextString();
        long k = in.nextLong();
        count = new long[s.length() + 1];
        count[s.length()] = 1;
        for (int i = s.length(); i >= 0; --i) {
            for (int j = i - 1; j >= 0; --j) {
                String tmp = s.substring(j, i);
                if (dict.containsKey(tmp)) {
                    count[j] += count[i];
                }
            }
        }
        if (count[0] < k) {
            out.print(0);
        } else {
            out.println(getKth(0, k));
        }
    }

    private String getKth(int pos, long k) {
        if (pos == s.length())
            return "";
        for (int c = 0; c < 26; ++c) {
            String g = idict.get((char) (c + 'A'));
            if (pos + g.length() <= s.length()) {
                String tmp = s.substring(pos, pos + g.length());
                if (tmp.equals(g)) {
                    if (count[pos + g.length()] <= k) {
                        return (char) (c + 'A') + getKth(pos + g.length(), k);
                    } else {
                        k -= count[pos + g.length()];
                    }
                }
            }
        }
        throw new RuntimeException();

    }
}
